package router

import (
	"haodayizhi/controll"
	middleware "haodayizhi/middle_ware"

	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	// 初始化路由
	r := gin.Default()
	r.Use(middleware.RateLimiter())
	r.Use(middleware.Cors())
	r.Use(middleware.ErrHandler())
	r.Use(middleware.AccessLogger())
	r.Use(middleware.ApiKeyMiddleware)
	r.Use(middleware.TimeMiddleware())
	Auth(r.Group("/auth"))
	User(r.Group("/user"))
	Product(r.Group("/prod"))
	Notice(r.Group("/notice"))
	r.GET("/events", middleware.AuthMiddleware(), controll.SSEHandler)
	return r
}
